package top.plgxs.basic.one;

import java.sql.SQLOutput;

/**
 * <p> 自动装箱与自动拆箱 </p>
 *
 * @author Stranger.
 * @since 2022/9/1 11:32
 */
public class Pack {
    // 装箱
    Integer a = 127;
    // 拆箱
    int b = a;
    // 实际执行代码
    Integer a1 = Integer.valueOf(127);
    int b1 = a1.intValue();

    public static void main(String[] args) {
        int x = 127;
        Integer x1 = 127;
        Integer x2 = 127;
        Integer x3 = new Integer(127);
        Integer x4 = new Integer(127);
        Integer x5 = Integer.valueOf(127);
        System.out.println((x == x1) + " , " + (x == x3) + " , " + (x1 == x2));
        System.out.println( (x1 == x3) + " , " + (x3 == x4) + " , " + (x3 == x5));

        int y = 128;
        Integer y1 = 128;
        Integer y2 = 128;
        Integer y3 = new Integer(128);
        Integer y4 = new Integer(128);
        Integer y5 = Integer.valueOf(128);
        System.out.println((y == y1) + " , " + (y == y3) + " , " + (y1 == y2));
        System.out.println( (y1 == y3) + " , " + (y3 == y4) + " , " + (y3 == y5));

        boolean b = true;
        Boolean b1 = true;
        Boolean b2 = true;
        Boolean b3 = new Boolean(true);
        System.out.println((b == b1) + " , " + (b == b3) + " , " + (b1 == b2) + " , " + (b1 == b3));

        char c = 'A';
        Character c1 = 'A';
        Character c2 = 'A';
        Character c3 = new Character('A');
        System.out.println((c == c1) + " , " + (c == c3) + " , " + (c1 == c2) + " , " + (c1 == c3));

        double d = 1.1;
        Double d1 = 1.1;
        Double d2 = 1.1;
        Double d3 = new Double(1.1);
        System.out.println((d == d1) + " , " + (d == d3) + " , " + (d1 == d2) + " , " + (d1 == d3));

    }
}
